<script>
    var baseUrl = "<?php echo $baseUrl; ?>?t=1";
    var imgurl = "<?php echo $imgurl; ?>";
</script>
<style type="text/css">
    .hide{display: none;}
    #box{overflow: hidden;overflow-y: auto;}
    .noticebox{width: 100%;}
    .basesys.notice{margin-bottom: 10px;}
    .delnotice{margin-left: 10px;}
    .addnotice{margin-left: 10px;}
    .clear{height: 1px;width: 100%;clear: both;}
    .width200{width: 350px;float: left;}
    .zhushinitice{margin-bottom: 10px;height: 38px;line-height: 38px;}
    #buy_notice,#retreat_notice,#rebate_notice { height: 200px;overflow: hidden;overflow-y: auto; }
    .layui-upload-img{width: 184px; height: 92px; margin: 0 10px 10px 0;}
    .bannerimg{height: 35px;width: 70px;}
    .addbtn{height: 38px;}
    .addbtn i{font-size: 30px;line-height: 38px;}
    .addbtn i:hover{color: #1f93ff;cursor: pointer;}
</style>

<div class="layui-tab">
  <ul class="layui-tab-title">
    <li class="layui-this" onclick="app.info('base')">系统参数</li>
    <li onclick="app.info('rule')">退改规则</li>
    <li onclick="app.info('banner')">轮播图</li>
  </ul>
  <div class="layui-tab-content" id="box">
    <div class="layui-tab-item layui-show" id="base">

    </div>
    <div class="layui-tab-item" id="rule">
        <div class="layui-row layui-col-space122">
            <div class="layui-col-md12" id="app-list">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <?php if(Cm::$app->limitPost('/platform/sys/index','save')){ ?>
                        <a href="javascript:void(0)" class="layui-btn layui-btn-primary layui-btn-sm" onclick="app.retreatchange.add(0)">+ 新增规则</a>
                        <?php } ?>
                    </div>
                    <div class="layui-card-body">
                        <table data-url="<?php echo $baseUrl; ?>?action=list"
                               data-search="#search-box"
                               data-page=""
                               id="data-list"
                               lay-filter='data-list' style="display: none;">
                            <thead>
                            <tr>
                                <th width="80" align="center" field="ids">序号</th>
                                <th width="150" field="name">规则名称</th>
                                <th width="120" field="typestr">类型</th>
                                <th width="250" field="circuitstr">使用路线</th>
                                <th width="80" align="center" templet="#tpl-status">状态</th>
                                <th minWidth="300" toolbar="#tpl-cmd">操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-tab-item" id="banner">
        <div class="layui-row layui-col-space122">
            <div class="layui-col-md12" id="app-list">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <?php if(Cm::$app->limitPost('/platform/sys/index','bannersave')){ ?>
                        <a href="javascript:void(0)" class="layui-btn layui-btn-primary layui-btn-sm" onclick="app.banner.add(this,0)">+ 新增轮播图</a>
                        <?php } ?>
                    </div>
                    <div class="layui-card-body">
                        <table data-url="<?php echo $baseUrl; ?>?action=bannerlist"
                               data-search="#search-box"
                               data-page=""
                               id="banner-list"
                               lay-filter='data-list' style="display: none;">
                            <thead>
                            <tr>
                                <th width="80" align="center" field="ids">序号</th>
                                <th width="150" align="center" templet="#tpl-banner-img">轮播图</th>
                                <th width="250" align="center" field="sort">排序</th>
                                <th width="250" field="link_url">连接地址</th>
                                <th width="80" align="center" templet="#tpl-banner-status">状态</th>
                                <th minWidth="300" toolbar="#tpl-banner-cmd">操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
  </div>
</div>
<!-- 基本 -->
<script type="text/html" id="tpl-info-base">
    <div class="layui-form-item">
        <label class="layui-form-label">客服电话</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.sys_telephone ? item.sys_telephone.value : '暂未设置'}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">服务费</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.sys_service_charge ? "￥"+item.sys_service_charge.value : '暂未设置'}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">保险费</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.sys_premium ? "￥"+item.sys_premium.value : '暂未设置'}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">改签上限</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.sys_order_change ? item.sys_order_change.value+'次' : '暂未设置'}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">转车上限</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.sys_car_change ? item.sys_car_change.value+'次' : '暂未设置'}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">拼车上限</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.sys_car_pooling ? item.sys_car_pooling.value+'次' : '暂未设置'}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">购票须知</label>
        <div class="layui-input-block">
            <div id="buy_notice"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">退票须知</label>
        <div class="layui-input-block">
            <div id="retreat_notice"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分销规则</label>
        <div class="layui-input-block">
            <div id="rebate_notice"></div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">分销开关</label>
        <div class="layui-input-block">
            {{item.sys_rebate_status ? (item.sys_rebate_status.value==1?'开':'关'): '关'}}
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">分销方式</label>
        <div class="layui-input-block">
            {{item.sys_rebate_type ? (item.sys_rebate_type.value==1?'售价比列':'分销金额'): '分销金额'}}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">{{item.sys_rebate_type ? (item.sys_rebate_type.value==2?'分销金额':'分销比列'): '分销金额'}}</label>
        <div class="layui-input-block">
            {{item.sys_rebate ? item.sys_rebate.value+(item.sys_rebate_type.value==1?'%(设置时值不应小于0，大于100)':'(元)') : '暂未设置'}}
        </div>
    </div>
    <?php if(Cm::$app->limitPost('/platform/sys/index','info')){ ?>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" onclick="app.edit('base')">编辑</button>
        </div>
    </div>
    <?php } ?>
</script>
<script type="text/html" id="tpl-edit-base">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">客服电话</label>
            <div class="layui-input-inline">
                <input type="text" name="sys_telephone" lay-verify="required"  value="{{item.sys_telephone ? item.sys_telephone.value : ''}}" autocomplete="off" placeholder="请输入客服电话" class="layui-input basesys">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">服务费</label>
            <div class="layui-input-inline">
                <input type="text" name="sys_service_charge" lay-verify="required|price"  value="{{item.sys_service_charge ? item.sys_service_charge.value : ''}}" autocomplete="off" placeholder="请输入客服电话" class="layui-input basesys">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">保险费</label>
            <div class="layui-input-inline">
                <input type="text" name="sys_premium" lay-verify="required|price"  value="{{item.sys_premium ? item.sys_premium.value : ''}}" autocomplete="off" placeholder="请输入保险费" class="layui-input basesys">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">改签上限</label>
            <div class="layui-input-inline">
                <input type="text" name="sys_order_change" lay-verify="required|intnumber"  value="{{item.sys_order_change ? item.sys_order_change.value : 1}}" autocomplete="off" placeholder="请输入订单改签最大次数" class="layui-input basesys">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">转车上限</label>
            <div class="layui-input-inline">
                <input type="text" name="sys_car_change" lay-verify="required|intnumber"  value="{{item.sys_car_change ? item.sys_car_change.value : 1}}" autocomplete="off" placeholder="请输入订单转车最大次数" class="layui-input basesys">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">拼车上限</label>
            <div class="layui-input-inline">
                <input type="text" name="sys_car_pooling" lay-verify="required|intnumber"  value="{{item.sys_car_pooling ? item.sys_car_pooling.value : 1}}" autocomplete="off" placeholder="请输入订单拼车最大次数" class="layui-input basesys">
            </div>
        </div>
        <div class="layui-form-item buynoticebox">
            <label class="layui-form-label">购票须知</label>
            <div class="layui-input-block">
                <textarea id="buynotice" cols="30" rows="10" name="sys_buy_notice">{{item.sys_buy_notice ? item.sys_buy_notice.value : ''}}</textarea>
            </div>
        </div>
        <div class="layui-form-item retreatnoticebox">
            <label class="layui-form-label">退票须知</label>
            <div class="layui-input-block">
                <textarea id="retreatnotice" cols="30" rows="10" name="sys_retreat_notice">{{item.sys_buy_notice ? item.sys_retreat_notice.value : ''}}</textarea>
            </div>
        </div>

        <div class="layui-form-item rebatenoticebox">
            <label class="layui-form-label">分销规则</label>
            <div class="layui-input-block">
                <textarea id="rebatenotice" cols="30" rows="10" name="sys_rebate_notice">{{item.sys_buy_notice ? item.sys_rebate_notice.value : ''}}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">分销开关</label>
            <div class="layui-input-block" style="display: flex">
                        <input type="radio" id="radio1" name="sys_rebate_status" style="display: block;width: 20px;height: 20px;opacity: 0.5" value="0"
                               title="关" {{item.sys_rebate_status ? (item.sys_rebate_status.value==1?'':'checked'): 'checked'}}>
                        <label for="radio1">关</label>
                        <input type="radio" id="radio2" name="sys_rebate_status" style="display: block;width: 20px;height: 20px;opacity: 0.5" value="1"
                               title="开" {{item.sys_rebate_status ? (item.sys_rebate_status.value==0?'':'checked'): 'checked'}}>
                        <label for="radio2">开</label>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分销方式</label>
            <div class="layui-input-block" style="display: flex">
                <input type="radio" id="radio3" name="sys_rebate_type" style="display: block;width: 20px;height: 20px;opacity: 0.5" value="1"
                       title="售价比列" {{item.sys_rebate_type ? (item.sys_rebate_type.value==2?'':'checked'): 'checked'}}>
                <label for="radio3">售价比列</label>
                <input type="radio" id="radio4" name="sys_rebate_type" style="display: block;width: 20px;height: 20px;opacity: 0.5" value="2"
                       title="金额" {{item.sys_rebate_type ? (item.sys_rebate_type.value==1?'':'checked'): 'checked'}}>
                <label for="radio4">金额</label>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{{item.sys_rebate_type ? (item.sys_rebate_type.value==2?'分销金额':'分销比列'): '分销金额'}}</label>
            <div class="layui-input-inline">
                <input type="number" name="sys_rebate" lay-verify="required|price"  value="{{item.sys_rebate ? item.sys_rebate.value : 1}}"
                       autocomplete="off" placeholder="请输入订单分销金额或比例" class="layui-input basesys"
                     min="0.1" max="100" step="0.1" onkeyup ="value=value.replace(/^(\d*\.?\d{0,2}).*/,'$1')"
                >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <?php if(Cm::$app->limitPost('/platform/sys/index','save')){ ?>
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sys">保存</button>
                <?php } ?>
                <button class="layui-btn" onclick="app.info('base')">返回</button>
            </div>
        </div>
    </form>
</script>
<!-- 退改 -->
<script type="text/html" id="tpl-status">
    {{# if(d.status == 1){ }}
    <span class="layui-btn layui-btn-xs">启用</span>
    {{# }else{ }}
    <span class="layui-btn layui-btn-xs layui-btn-danger">停用</span>
    {{# } }}
</script>
<script type="text/html" id="tpl-cmd">
    <?php if(Cm::$app->limitPost('/platform/sys/index','save')){ ?>
        <button onclick="app.retreatchange.info(this,'')" class="layui-btn layui-btn-xs">编辑</button>
    <?php } ?>
    <?php if(Cm::$app->limitPost('/platform/sys/index','info')){ ?>
        <button onclick="app.retreatchange.info(this,'tpl-info-rule')" class="layui-btn layui-btn-xs">查看</button>
    <?php } ?>
    <?php if(Cm::$app->limitPost('/platform/sys/index','startstop')){ ?>
        {{# if(d.status == 0){ }}
        <button onclick="app.retreatchange.startstop({{d.id}},{{d.status}})" class="layui-btn layui-btn-xs">启用</button>
        {{# }else{ }}
        <button onclick="app.retreatchange.startstop({{d.id}},{{d.status}})" class="layui-btn layui-btn-xs layui-btn-danger">停用</button>
        {{# } }}
    <?php } ?>
    <?php if(Cm::$app->limitPost('/platform/sys/index','del')){ ?>
        <button onclick="app.retreatchange.del({{d.id}})" class="layui-btn layui-btn-xs layui-btn-danger">删除</button>
    <?php } ?>
    <span style="display: none;">{{JSON.stringify(d)}}</span>
</script>
<script type="text/html" id="tpl-info-rule">
    <div class="layui-form-item">
        <label class="layui-form-label">规则名称</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.name}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">规则类型</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.typestr}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <div class="zhushinitice">{{item.status == 0 ? '停用' : '启用'}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">适用路线</label>
        <div class="layui-input-block">
            <div class="zhushinitice">{{item.circuitstr}}</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">规则内容</label>
        <div class="layui-input-block">
            <div class="zhushinitice">
                {{if item.type==1 }}
                生成订单{{item.value}}分钟后完成支付,超时未支付,订单将失效
                {{else if item.type==2}}
                生成订单{{item.value==0?'不':''}}占用余票名额
                {{else if item.type==3}}
                发车时间{{item.value}}分钟后停止检票,订单状态系统会自动改为“已发车”
                {{else if item.type==4}}
                发车时间{{item.value}}分钟后订单状态系统会自动改为“已完成”
                {{else if item.type==5}}
                没有到发车时间前{{item.value}}分钟订单都可改签,即发车时间前{{item.value}}分钟到发车时间是不能改签的
                {{else if item.type==6}}
                发车时间{{item.value}}天前可以全款退票
                {{else if item.type==7}}
                发车时间前{{item.value}}分钟内不能退票
                {{else if item.type==8}}
                发车时间前{{item.value.start}}天到{{item.value.end}}天退票收取{{item.value.service}}%比例的手续费。
                {{/if}}
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="tpl-add-rule">
    <div class="layui-card" style="box-shadow: none;">
        <div style="width: 1px;height: 1px;overflow: hidden;">
            <input type="text">
            <input type="password">
        </div>
        <div class="layui-card-header">新增规则</div>
        <div class="layui-card-body">
            <form class="layui-form" action="">

                <div class="layui-form-item">
                    <label class="layui-form-label">规则类型</label>
                    <div class="layui-input-block" id="rule_type_box">
                        <?php foreach ($rule_type as $key => $value) { ?>
                        <input type="radio" name="type" id="rule_type<?php echo $key; ?>" lay-filter="rule_type" value="<?php echo $key; ?>" title="<?php echo $value; ?>">
                        <?php } ?>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">规则名称</label>
                    <div class="layui-input-inline">
                        <input type="text" value="{{item.name}}" name="name" lay-verify="required"  autocomplete="off" placeholder="请输入规格名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">启用状态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="rule_status" name="status" lay-skin="switch" lay-text="ON|OFF" {{item.status==1?'checked':''}}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">使用路线</label>
                    <div class="layui-input-inline">
                        <select  name="circuit" id="circuit" lay-filter="rule_circuit" lay-search="">
                            <option value="0">通用</option>
                            <?php foreach ($circuitlist as $key => $value){ ?>
                                <option value="<?php echo $value['id']?>"><?php echo $value['name']?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="rule_info_box">

                </div>
                <?php if(Cm::$app->limitPost('/platform/sys/index','save')){ ?>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="rule">保存</button>
                    </div>
                </div>
                <?php } ?>
            </form>
        </div>
    </div>
</script>
<script type="text/html" id="tpl_rule_buy">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:生成订单多少分钟后完成支付,超时未支付,订单将失效。(大于0的整数)</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline">
            <input type="text" value="{{value}}" name="add_order_time" lay-verify="required|intnumber"  autocomplete="off" placeholder="请输入下单后多少分钟" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">分钟</div>
    </div>
</script>
<script type="text/html" id="tpl_rule_s_ticket">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:生成订单是否占用余票名额。</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否占用</label>
        <div class="layui-input-inline">
            <input type="checkbox" lay-filter="rule_s_ticket_status" name="s_ticket_status" lay-skin="switch" lay-text="ON|OFF" {{value==1?'checked':''}}>
        </div>
    </div>
</script>
<script type="text/html" id="tpl_rule_ticket_checking">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:发车时间多少分钟后停止检票,订单状态系统会自动改为“已发车”。(大于0的整数)</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline">
            <input type="text" value="{{value}}" name="checking_order_time" lay-verify="required|intnumber"  autocomplete="off" placeholder="请输入发车后多少分钟" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">分钟</div>
    </div>
</script>
<script type="text/html" id="tpl_rule_order_complete_time">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:发车时间多少分钟后订单状态系统会自动改为“已完成”。(大于0的整数)</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline">
            <input type="text" value="{{value}}" name="complete_order_time" lay-verify="required|intnumber"  autocomplete="off" placeholder="请输入发车后多少分钟" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">分钟</div>
    </div>
</script>
<script type="text/html" id="tpl_rule_ticket_change">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:没有到发车时间前多少分钟订单都可改签,即发车时间前多少分钟是不能改签的。(大于0的整数)</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline">
            <input type="text" value="{{value}}" name="change_order_time" lay-verify="required|intnumber"  autocomplete="off" placeholder="请输入提前多小分钟" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">分钟</div>
    </div>
</script>
<script type="text/html" id="tpl_rule_ticket_refund_all_price">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:发车时间多少天前可以全款退票。(大于0的整数)</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline">
            <input type="text" value="{{value}}" name="refund_all_price_time" lay-verify="required|intnumber"  autocomplete="off" placeholder="请输入提前多少天" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">天</div>
    </div>
</script>
<script type="text/html" id="tpl_rule_ticket_refund_no">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:发车时间前多少分钟内不能退票。(大于0的整数)</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline">
            <input type="text" value="{{value}}" name="refund_no_time" lay-verify="required|intnumber"  autocomplete="off" placeholder="请输入提前多少分钟" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">分钟</div>
    </div>
</script>
<script type="text/html" id="tpl_rule_ticket_refund_part_price">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="zhushi">注:发车时间前多少天到多少天退票收取多少比例的手续费。包含发车当天。(天数为大于0的整数,比例为大于0且小于100的2位小数)</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <a href="javascript:void(0)" class="layui-btn layui-btn-primary layui-btn-sm" onclick="app.retreatchange.addrulenum()">+ 新增规则</a>
        </div>
    </div>
    <div class="ticket_refund_part_price_box">
        {{if value}}
            {{each value.start as item index}}
                <div class="layui-form-item rulenum{{index+1}}">
                    <label class="layui-form-label">规则{{index+1}}</label>
                    <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux">发车前</div>
                            <input type="text" value="{{item}}" name="refund_part_start_time{{index+1}}" lay-verify="required|intzeronumber"  autocomplete="off" class="layui-input refund_part_start_time" readonly="readonly" style="width: 55px;float: left;">
                            <div class="layui-form-mid layui-word-aux">天</div>
                            <div class="layui-form-mid layui-word-aux" style="margin:0px 25px 0px 15px; ">到</div>
                            <input type="text" value="{{value.end[index]}}" name="refund_part_end_time{{index+1}}" lay-verify="required|intzeronumber"  autocomplete="off"  class="layui-input refund_part_end_time" style="width: 55px;float: left;">
                            <div class="layui-form-mid layui-word-aux">天</div>
                            <div class="layui-form-mid layui-word-aux">手续费</div>
                            <input type="text" value="{{value.service[index]}}" name="refund_part_service{{index+1}}" lay-verify="required|servicenumber"  autocomplete="off"  class="layui-input refund_part_service" style="width: 50px;float: left;">
                            <div class="layui-form-mid layui-word-aux">%</div>
                            <a href="javascript:void(0)" class="layui-btn layui-btn-danger layui-btn-sm delrulenum{{index+1}} {{index+1 == value.start.length ? '' : 'hide'}}" style="margin-top: 4px;" onclick="app.retreatchange.delrulenum()">-删除</a>
                    </div>
                </div>
            {{/each}}
        {{/if}}
    </div>
</script>
<script type="text/html" id="tpl_ticket_refund_part_price">
    <div class="layui-form-item rulenum{{num}}">
        <label class="layui-form-label">规则{{num}}</label>
        <div class="layui-input-block">
                <div class="layui-form-mid layui-word-aux">发车前</div>
                <input type="text" value="{{num == 1 ? 0 : start}}" name="refund_part_start_time{{num}}" lay-verify="required|intzeronumber"  autocomplete="off" class="layui-input refund_part_start_time" readonly="readonly" style="width: 55px;float: left;">
                <div class="layui-form-mid layui-word-aux">天</div>
                <div class="layui-form-mid layui-word-aux" style="margin:0px 25px 0px 15px; ">到</div>
                <input type="text" value="" name="refund_part_end_time{{num}}" lay-verify="required|intzeronumber"  autocomplete="off"  class="layui-input refund_part_end_time" style="width: 55px;float: left;">
                <div class="layui-form-mid layui-word-aux">天</div>
                <div class="layui-form-mid layui-word-aux">手续费</div>
                <input type="text" value="" name="refund_part_service{{num}}" lay-verify="required|servicenumber"  autocomplete="off"  class="layui-input refund_part_service" style="width: 50px;float: left;">
                <div class="layui-form-mid layui-word-aux">%</div>
                <a href="javascript:void(0)" class="layui-btn layui-btn-danger layui-btn-sm delrulenum{{num}}" style="margin-top: 4px;" onclick="app.retreatchange.delrulenum()">-删除</a>
        </div>
    </div>
</script>
<script type="text/html" id="tpl-banner">
    <div style="padding:10px;">
        <form class="layui-form" action="">
            <div class="layui-upload">
                <label class="layui-form-label">选择图片</label>
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" id="addimg">上传图片</button>
                    <div class="layui-upload-list" >
                        <img class="layui-upload-img" id="imgshow" {{if item.src!='' }}src="{{item.src}}"{{/if}}>
                        <p id="imgText"></p>
                    </div>
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-inline">
                    <input type="text" value="{{item.sort}}" name="sort" lay-verify="intzeronumber"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">连接地址</label>
                <div class="layui-input-block">
                    <input type="text" value="{{item.link_url}}" name="link_url" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <?php if(Cm::$app->limitPost('/platform/sys/index','bannersave')){ ?>
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="banner">保存</button>
                    <?php } ?>
                    <button class="layui-btn" onclick="app.close()">取消</button>
                </div>
            </div>
        </form>
    </div>
</script>
<script type="text/html" id="tpl-banner-img">
    {{# if(d.path!=''){ }}
    <img class="bannerimg" src="{{d.path}}">
    {{# } }}
</script>
<script type="text/html" id="tpl-banner-status">
    {{# if(d.status == 1){ }}
    <span class="layui-btn layui-btn-xs">启用</span>
    {{# }else{ }}
    <span class="layui-btn layui-btn-xs layui-btn-danger">停用</span>
    {{# } }}
</script>
<script type="text/html" id="tpl-banner-cmd">
    <?php if(Cm::$app->limitPost('/platform/sys/index','bannersave')){ ?>
        <button onclick="app.banner.add(this,{{d.id}})" class="layui-btn layui-btn-xs">编辑</button>
    <?php } ?>
    <button onclick="app.banner.showImg('{{d.path}}')"  class="layui-btn layui-btn-xs">查看大图</button>
    <?php if(Cm::$app->limitPost('/platform/sys/index','bannerstartstop')){ ?>
        {{# if(d.status == 0){ }}
        <button onclick="app.banner.startstop({{d.id}},{{d.status}})" class="layui-btn layui-btn-xs">启用</button>
        {{# }else{ }}
        <button onclick="app.banner.startstop({{d.id}},{{d.status}})" class="layui-btn layui-btn-xs layui-btn-danger">停用</button>
        {{# } }}
    <?php } ?>
    <?php if(Cm::$app->limitPost('/platform/sys/index','bannerdel')){ ?>
        <button onclick="app.banner.del({{d.id}})" class="layui-btn layui-btn-xs layui-btn-danger">删除</button>
    <?php } ?>
    <span style="display: none;">{{JSON.stringify(d)}}</span>
</script>
<script type="text/javascript">
    var app = {
        data: '<?php echo json_encode($config); ?>',
        config:'',
        sysdata:'',
        init: function () {
            app.config = JSON.parse(app.data);
            app.form.init();
            app.layedit.init();
            app.show();
            app.info('base');
            $('#data-list').table();
            $('#banner-list').table();
        },
        show:function(){
            var height = $(window).height()-210;
            $("#box").css("height",height+"px")
        },
        info:function(type){
            item = [];
            if(type == 'base'){
                item = app.config.sys;
                $("#"+type).html(template("tpl-info-"+type,{item:item}));
                var buyhtml = item.sys_buy_notice ? app.escape2Html(item.sys_buy_notice.value) : '暂未设置';
                $('#buy_notice').html(buyhtml);
                var retreathtml = item.sys_retreat_notice ? app.escape2Html(item.sys_retreat_notice.value) : '暂未设置';
                $('#retreat_notice').html(retreathtml);
                var rebatehtml = item.sys_rebate_notice ? app.escape2Html(item.sys_rebate_notice.value) : '暂未设置';
                $('#rebate_notice').html(rebatehtml);
            }

        },
        escape2Html:function(str) {
            var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
            return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){
                return arrEntities[t];
            });
        },
        form: {
            obj: null,
            init: function () {
                var form = layui.form;
                form.verify({
                    intnumber: [
                        /^([1-9]|[1-9]\d+)$/
                        , '请填写大于0的整数！'
                    ],
                    servicenumber:[
                        /^\d\.([1-9]{1,2}|[0-9][1-9])$|^[1-9]\d{0,1}(\.\d{1,2}){0,1}$|^100(\.0{1,2}){0,1}$/
                        , '请填写大于0小于等于100的2位小数！'
                    ],
                    intzeronumber:[
                        /^([0-9]|[1-9]\d+)$/
                        , '请填写大于等于0的整数！'
                    ],
                    price:[
                        /(^[1-9](\d+)?(\.\d{1,2})?$)|(^0$)|(^\d\.\d{1,2}$)/
                        , '请填写大于0的2位小数！'
                    ]
                });
                form.render();
                this.obj = form;
            },
            render: function () {
                this.obj.render();
            }
        },
        layedit:{
            obj: null,
            buyindex:'',
            retreatindex:'',
            rebateindex:'',
            init: function () {
                /*layui.use('layedit', function(){
                    app.layedit.obj = layui.layedit;
                    app.layedit.obj.set({
                        uploadImage: {
                            url: baseUrl+'&action=upload'
                            ,type: 'post'
                        }
                    });
                });*/
                layui.extend({
                    tinymce: '<?php echo RES_URL?>/res/js/tinymce/tinymce'
                }).use('tinymce', function () {
                    app.layedit.obj = layui.tinymce
                })
            },
        },
        edit:function(type){
            item = [];
            if(type == 'base'){
                item = app.config.sys;
            }
            $("#"+type).html(template("tpl-edit-"+type,{item:item}));
            if(app.layedit.buyindex == ''){
                app.layedit.buyindex = app.layedit.obj.render({
                    elem: "#buynotice"
                    , height: 250
                });
            }else{
                app.layedit.buyindex = app.layedit.obj.reload({
                    elem: "#buynotice"
                    , height: 250
                });
            }
            if(app.layedit.retreatindex == ''){
                app.layedit.retreatindex = app.layedit.obj.render({
                    elem: "#retreatnotice"
                    , height: 250
                });
            }else{
                app.layedit.retreatindex = app.layedit.obj.reload({
                    elem: "#retreatnotice"
                    , height: 250
                });
            }

            if(app.layedit.rebateindex == ''){
                app.layedit.rebateindex = app.layedit.obj.render({
                    elem: "#rebatenotice"
                    , height: 250
                });
            }else{
                app.layedit.rebateindex = app.layedit.obj.reload({
                    elem: "#rebatenotice"
                    , height: 250
                });
            }

            app.form.obj.on('submit(sys)', function (data) {
                data.field.type = 'sys';
                data.field.sys_buy_notice = app.layedit.obj.get('#buynotice').getContent();
                data.field.sys_retreat_notice = app.layedit.obj.get('#retreatnotice').getContent();
                data.field.sys_rebate_notice = app.layedit.obj.get('#rebatenotice').getContent();
                if(data.field.sys_buy_notice == ''){
                    layer.msg("请填写购票须知");
                    return false;
                }
                if(data.field.sys_retreat_notice == ''){
                    layer.msg("请填写退票须知");
                    return false;
                }
                if(data.field.sys_rebate_notice == ''){
                    layer.msg("请填写分销规则");
                    return false;
                }
                app.sysdata = data.field;
                app.syssave();
                return false;
            });
        },
        syssave:function(data){
            $.post(baseUrl+'&action=save',app.sysdata,function (d) {
                if(d.data.length == 0){
                    layer.msg("保存失败,"+d.msg);
                }else{
                    layer.msg("保存成功");
                    app.config.sys = d.data
                    app.info('base');
                }
            },'json')
        },
        retreatchange:{
            data:{
                id:0,
                rule_type:0,
                name:'',
                status:0,
                circuit:0,
                type:'rule',
                rule_value:'',
            },
            s_ticket_status:0,
            rule_info_tpl:{
                1:'tpl_rule_buy',
                2:'tpl_rule_s_ticket',
                3:'tpl_rule_ticket_checking',
                4:'tpl_rule_order_complete_time',
                5:'tpl_rule_ticket_change',
                6:'tpl_rule_ticket_refund_all_price',
                7:'tpl_rule_ticket_refund_no',
                8:'tpl_rule_ticket_refund_part_price'
            },
            json:{},
            rule_num:1,
            add:function(id){
                app.retreatchange.data.id = id;
                if(id == 0){
                    app.retreatchange.json = {};
                }
                layer.open({
                    title:false,
                    area:['630px','600px'],
                    type:1,
                    content:template('tpl-add-rule', {item:app.retreatchange.json})
                });
                if(id != 0){
                    app.retreatchange.data.circuit = app.retreatchange.json.circuit_id;
                    app.retreatchange.data.rule_type = app.retreatchange.json.type;
                    app.retreatchange.data.status = app.retreatchange.json.status;
                    $("#circuit").val(app.retreatchange.json.circuit_id);
                    html = "";
                    $.each(app.retreatchange.rule_info_tpl,function (index,item) {
                        if(index == app.retreatchange.json.type){
                            if(index == 8){
                                app.retreatchange.rule_num = app.retreatchange.json.value.start.length;
                            }
                            html = template(item,{value:app.retreatchange.json.value});
                            $("#rule_type"+index).attr("checked","checked");
                        }
                    });
                    $(".rule_info_box").html(html);
                }
                app.form.obj.render();
                app.form.obj.on('select(rule_circuit)', function(data){
                    app.retreatchange.data.circuit = data.value;
                });
                app.form.obj.on('switch(rule_status)', function(data){
                    app.retreatchange.data.status = data.elem.checked ? 1 : 0;
                });
                app.form.obj.on('switch(rule_s_ticket_status)', function(data){
                    app.retreatchange.s_ticket_status = data.elem.checked ? 1 : 0;
                });

                app.form.obj.on('radio(rule_type)', function(data){
                    var val = data.value;
                    app.retreatchange.data.rule_type = val;
                    var html = "";
                    $.each(app.retreatchange.rule_info_tpl,function (index,item) {
                        if(index == val){
                            html = template(item,{});
                        }
                    });
                    $(".rule_info_box").html(html);
                    if(val == 8){
                        app.retreatchange.rule_num = 1;
                        $(".ticket_refund_part_price_box").html(template('tpl_ticket_refund_part_price',{num:1,start:''}));
                    }
                    app.form.obj.render();
                });
                app.form.obj.on('submit(rule)', function (data) {
                    if(app.retreatchange.data.rule_type == 0){
                        layer.msg("请选择规则类型!", {icon: 5});
                        return false;
                    }else if(app.retreatchange.data.rule_type == 1){
                        app.retreatchange.data.rule_value = data.field.add_order_time;
                    }else if(app.retreatchange.data.rule_type == 2){
                        app.retreatchange.data.rule_value = app.retreatchange.s_ticket_status;
                    }else if(app.retreatchange.data.rule_type == 3){
                        app.retreatchange.data.rule_value = data.field.checking_order_time;
                    }else if(app.retreatchange.data.rule_type == 4){
                        app.retreatchange.data.rule_value = data.field.complete_order_time;
                    }else if(app.retreatchange.data.rule_type == 5){
                        app.retreatchange.data.rule_value = data.field.change_order_time;
                    }else if(app.retreatchange.data.rule_type == 6){
                        app.retreatchange.data.rule_value = data.field.refund_all_price_time;
                    }else if(app.retreatchange.data.rule_type == 7){
                        app.retreatchange.data.rule_value = data.field.refund_no_time;
                    }else if(app.retreatchange.data.rule_type == 8){
                        var start = [];
                        var end = [];
                        var service = [];
                        if(app.retreatchange.rule_num >= 1){
                            var etime1 = parseInt(data.field.refund_part_end_time1);
                            var stime1 = parseInt(data.field.refund_part_start_time1);
                            var service1 = parseFloat(data.field.refund_part_service1);
                            if(etime1<=stime1){
                                layer.msg("规则1的結束时间天数必须大于开始时间天数！", {icon: 5});
                                return false;
                            }
                            start.push(stime1);
                            end.push(etime1);
                            service.push(service1);
                        }
                        if(app.retreatchange.rule_num >= 2){
                            var etime2 = parseInt(data.field.refund_part_end_time2);
                            var stime2 = parseInt(data.field.refund_part_start_time2);
                            var service2 = parseFloat(data.field.refund_part_service2);
                            if(stime2 != etime1){
                                layer.msg("规则2的开始时间天数必须等于规则1的结束时间天数！", {icon: 5});
                                return false;
                            }
                            if(etime2<=stime2){
                                layer.msg("规则2的結束时间天数必须大于开始时间天数！", {icon: 5});
                                return false;
                            }
                            if(service2>=service1){
                                layer.msg("规则2的手续费必须小于规则1的手续费！", {icon: 5});
                                return false;
                            }
                            start.push(stime2);
                            end.push(etime2);
                            service.push(service2);
                        }
                        if(app.retreatchange.rule_num >= 3){
                            var etime3 = parseInt(data.field.refund_part_end_time3);
                            var stime3 = parseInt(data.field.refund_part_start_time3);
                            var service3 = parseFloat(data.field.refund_part_service3);
                            if(stime3 != etime2){
                                layer.msg("规则3的开始时间天数必须等于规则2的结束时间天数！", {icon: 5});
                                return false;
                            }
                            if(etime3<=stime3){
                                layer.msg("规则3的結束时间天数必须大于开始时间天数！", {icon: 5});
                                return false;
                            }
                            if(service3>=service2){
                                layer.msg("规则3的手续费必须小于规则2的手续费！", {icon: 5});
                                return false;
                            }
                            start.push(stime3);
                            end.push(etime3);
                            service.push(service3);
                        }
                        if(app.retreatchange.rule_num >= 4){
                            var etime4 = parseInt(data.field.refund_part_end_time4);
                            var stime4 = parseInt(data.field.refund_part_start_time4);
                            var service4 = parseFloat(data.field.refund_part_service4);
                            if(stime4 != etime3){
                                layer.msg("规则4的开始时间天数必须等于规则3的结束时间天数！", {icon: 5});
                                return false;
                            }
                            if(etime4<=stime4){
                                layer.msg("规则4的結束时间天数必须大于开始时间天数！", {icon: 5});
                                return false;
                            }
                            if(service4>=service3){
                                layer.msg("规则4的手续费必须小于规则3的手续费！", {icon: 5});
                                return false;
                            }
                            start.push(stime4);
                            end.push(etime4);
                            service.push(service4);

                        }
                        var refund = {
                            start:start,
                            end:end,
                            service:service
                        };
                        app.retreatchange.data.rule_value = JSON.stringify(refund);
                    }
                    app.retreatchange.data.name = data.field.name;
                    app.rulesave();
                    return false;
                });
            },
            addrulenum:function(){
                if(app.retreatchange.rule_num == 4){
                    layer.msg('已达上限，不能再添加新的规则', {icon: 5});
                    return false;
                }
                var intnumber = /^([0-9]|[1-9]\d+)$/;
                var servicenumber = /^\d\.([1-9]{1,2}|[0-9][1-9])$|^[1-9]\d{0,1}(\.\d{1,2}){0,1}$|^100(\.0{1,2}){0,1}$/;
                var isok = 1;
                var start = '';
                $(".refund_part_start_time").each(function(i,val){
                    start = parseInt($(this).val());
                    if(!intnumber.test(start)){
                        isok = 0;
                    }
                })
                if(isok == 0){
                    layer.msg("天数请填写大于等于0的整数！", {icon: 5});
                    return false;
                }
                var  end = '';
                $(".refund_part_end_time").each(function(i,val){
                    end = parseInt($(this).val());
                    if(!intnumber.test(end)){
                        isok = 0;
                    }
                })
                if(isok == 0){
                    layer.msg("天数请填写大于等于0的整数！", {icon: 5});
                    return false;
                }
                var service = '';
                var serviceok = 1;
                $(".refund_part_service").each(function(i,val){
                    if(i>0 && service <= parseInt($(this).val())){
                        serviceok = 0;
                    }
                    service = parseInt($(this).val());
                    if(!servicenumber.test(service)){
                        isok = 0;
                    }
                })
                if(isok == 0){
                    layer.msg("手续费请填写大于0小于等于100的2位小数！", {icon: 5});
                    return false;
                }
                if(serviceok == 0){
                    layer.msg("手续费必须逐级减小！", {icon: 5});
                    return false;
                }
                if(start >= end && app.retreatchange.rule_num >= 1){
                    layer.msg("开始天数必须小于结束天数", {icon: 5});
                    return false;
                }


                $(".delrulenum"+app.retreatchange.rule_num).hide();
                app.retreatchange.rule_num ++;
                $(".ticket_refund_part_price_box").append(template('tpl_ticket_refund_part_price',{num:app.retreatchange.rule_num,start:end}));
            },
            delrulenum:function(){
                $(".rulenum"+app.retreatchange.rule_num).remove();
                app.retreatchange.rule_num -- ;
                $(".delrulenum"+app.retreatchange.rule_num).show();
                $(".delrulenum"+app.retreatchange.rule_num).css("display","inline-block")
            },
            del:function(id){
                layer.msg("确定删除该退改规则吗？", {
                    time: false,
                    btn: ['确定', '取消'],
                    yes:function () {
                        $.post(baseUrl+'&action=del',{id:id},function (d) {
                            layer.closeAll();
                            if(d.flag)
                            {
                                layer.msg('删除成功');
                                $('#data-list').table();
                            }else{
                                layer.msg(d.msg);
                            }
                        },'json')
                    }
                });
            },
            startstop:function(id,status){
                var str = status == 0 ? '启用' : '停用';
                layer.msg("确定"+str+"该退改规则吗？", {
                    time: false,
                    btn: ['确定', '取消'],
                    yes:function () {
                        $.post(baseUrl+'&action=startstop',{id:id,status:status},function (d) {
                            layer.closeAll();
                            if(d.flag)
                            {
                                layer.msg(str+'成功');
                                $('#data-list').table();
                            }else{
                                layer.msg(d.msg);
                            }
                        },'json')
                    }
                });
            },
            info:function(e,tpl){
                var str=$(e).parent().find('span').html();
                var json=eval('('+str+')');
                if(json.type == '8'){
                    json.value = eval('('+json.value+')');
                }
                if(tpl == ''){
                    app.retreatchange.json = json;
                    app.retreatchange.add(json.id);
                }else{
                    layer.open({
                        title:false,
                        area:['450px','350px'],
                        type:1,
                        content:template(tpl, {item:json})
                    });
                }
            }
        },
        rulesave:function(){
            $.post(baseUrl+'&action=save',app.retreatchange.data,function (d) {
                if(d.flag)
                {
                    layer.closeAll();
                    layer.msg("保存成功");
                    $('#data-list').table();
                }else{
                    layer.msg(d.msg);
                }
            },'json')
        },
        banner:{
            data:{
                path:'',
                sort: 0,
                link_url:''
            },
            id:0,
            add:function(e,id){
                if(id == 0){
                    app.banner.data = {
                        path:'',
                        sort: 0,
                        link_url:'',
                        src:''
                    }
                }else{
                    var str=$(e).parent().find('span').html();
                    var json=eval('('+str+')');
                    app.banner.data = {
                        path:json.path,
                        sort: json.sort,
                        link_url:json.link_url,
                        src: imgurl+json.path
                    }
                }
                app.banner.id = id;
                layer.open({
                    title:false,
                    area:['450px','350px'],
                    type:1,
                    content:template('tpl-banner',{item:app.banner.data}),
                });
                layui.use('upload', function(){
                  var upload = layui.upload;
                    var uploadInst = upload.render({
                        elem: '#addimg'
                        ,url: baseUrl+'&action=bannerupload'
                        ,before: function(obj){
                            obj.preview(function(index, file, result){
                                $('#imgshow').attr('src', result);
                            });
                        }
                        ,done: function(res){
                            if(res.flag){
                                app.banner.data.path = res.data.path
                            }else{
                                return layer.msg('上传失败');
                            }
                        }
                        ,error: function(){
                            var imgText = $('#imgText');
                            imgText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                            imgText.find('.demo-reload').on('click', function(){
                                uploadInst.upload();
                            });
                        }
                    });
                });
                app.form.render();
                app.form.obj.on('submit(banner)', function (data) {
                    if(app.banner.data.path == ''){
                        layer.msg("请选择图片!", {icon: 5});
                        return false;
                    }
                    app.banner.data.sort = data.field.sort;
                    app.banner.data.link_url = data.field.link_url;
                    if(app.banner.id != 0){
                        app.banner.data.id = app.banner.id;
                    }
                    app.banner.save();
                    return false;
                });
            },
            save:function(){
                $.post(baseUrl+'&action=bannersave',app.banner.data,function (d) {
                    if(d.flag)
                    {
                        layer.closeAll();
                        layer.msg("保存成功");
                        $('#banner-list').table();
                    }else{
                        layer.msg(d.msg);
                    }
                },'json')
            },
            del:function(id){
                layer.msg("确定删除该轮播图吗？", {
                    time: false,
                    btn: ['确定', '取消'],
                    yes:function () {
                        $.post(baseUrl+'&action=bannerdel',{id:id},function (d) {
                            layer.closeAll();
                            if(d.flag)
                            {
                                layer.msg('删除成功');
                                $('#banner-list').table();
                            }else{
                                layer.msg(d.msg);
                            }
                        },'json')
                    }
                });
            },
            startstop:function(id,status){
                var str = status == 0 ? '启用' : '停用';
                layer.msg("确定"+str+"该轮播图吗？", {
                    time: false,
                    btn: ['确定', '取消'],
                    yes:function () {
                        $.post(baseUrl+'&action=bannerstartstop',{id:id,status:status},function (d) {
                            layer.closeAll();
                            if(d.flag)
                            {
                                layer.msg(str+'成功');
                                $('#banner-list').table();
                            }else{
                                layer.msg(d.msg);
                            }
                        },'json')
                    }
                });
            },
            showImg:function(src){
                var img = new Image();
                img.src = src;
                var height = img.height; // 原图片大小
                var width = img.width; //原图片大小

                var winHeight = $(window).height() - 80;
                var winWidth = $(window).width() - 100;
                if (height > winHeight || width > winWidth) {
                    if (winWidth/ winHeight <= width / height) {
                        width = winWidth;
                        height = winWidth * (height / width);
                    }

                    if (winWidth/ winHeight > width / height) {
                        width = winHeight  * (width / height);
                        height = winHeight  ;
                    }
                }

                var imgHtml = "<img src='" + img.src + "' width='" + width + "px' height='" + height + "px' />";
                layer.open({
                    type: 1,
                    shade: 0.8,
                    offset: 'auto',
                    area: [width + 'px',(height + 50) + 'px'],
                    shadeClose:true,
                    scrollbar: false,
                    title: "图片预览",
                    content: imgHtml,
                });
            }
        },
        close:function(){
            layer.closeAll();
        }
    }
    app.init();
</script>